//
//  NSProgressMgImplicitly.m
//  NSProgress
//
//  Created by 韩艳锋 on 2021/11/15.
//

#import "NSProgressMgImplicitly.h"

@implementation NSProgressMgImplicitly
- (instancetype)init {
    self = [super init];
    if (self) {
        [self startLongOperation];
    }
    return self;
}

- (void)startLongOperation {
    self.progress1 = [NSProgress progressWithTotalUnitCount:_totalProgress1];
 
    [self.progress1 becomeCurrentWithPendingUnitCount:_pendingUnitCount1];
    [self work1];
    [self.progress1 resignCurrent];
 
    [self.progress1 becomeCurrentWithPendingUnitCount:_totalProgress1 - _pendingUnitCount1];
    [self work2];
    [self.progress1 resignCurrent];
}
 
- (void)work1 {
    self.progress2 = [NSProgress progressWithTotalUnitCount:_totalProgress2];
    // Perform first task.
}
 
- (void)work2 {
    self.progress3 = [NSProgress progressWithTotalUnitCount:_totalProgress3];
    // Perform second task.
}

@end
